<%@page import="com.swt.mto.thithu.service.QuizCategoryLocalServiceUtil"%>
<%@page import="com.swt.mto.thithu.model.Quiz"%>
<%@page import="com.liferay.portal.kernel.util.ContextPathUtil"%>
<%@page import="com.swt.mto.thithu.model.QuizCategory"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.lang.reflect.Array"%>
<%@page import="java.util.Random"%>
<%@page import="com.swt.mto.thithu.portlet.ExamPortlet"%>
<%@page import="com.liferay.portal.kernel.language.LanguageUtil"%>
<%@page import="com.swt.mto.thithu.service.persistence.AnswerUtil"%>
<%@page import="com.swt.mto.thithu.service.AnswerLocalServiceUtil"%>
<%@page import="com.swt.mto.thithu.model.Answer"%>
<%@page import="com.swt.mto.thithu.service.QuestionLocalServiceUtil"%>
<%@page import="com.swt.mto.thithu.model.Question"%>
<%@page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<portlet:defineObjects />
<%
	List<Question> questions = QuestionLocalServiceUtil.getQuestionByQuiz(1);
	int questionCount = questions.size();
%>
<style type="text/css">
	#defaultCountdown {
		width: 240px;
		height: 45px;
	}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		
		
		//menu
		$("#accordian ul ul").slideUp();
		$("#accordian h3.menu1").click(function() {
			//slide up all the link lists
			$("#accordian ul ul").slideUp();
			//slide down the link list below the h3 clicked - only if its closed
			if (!$(this).next().is(":visible")) {
				$(this).next().slideDown();
			}
		});
		
		$("#accordian h3.menu2").click(function(){
			$("#accordian ul ul ul").slideUp();
			//slide down the link list below the h3 clicked - only if its closed
			if (!$(this).next().is(":visible")) {
				$(this).next().slideDown();
			}
		});
	});	
	
</script>


<%
	List<QuizCategory> categorieParent = QuizCategoryLocalServiceUtil.getCateByParentId(0);

%>


 <div id="accordian">
	<ul>
	<%
 	for(QuizCategory quizCatelogy : categorieParent){
 		%>
		<li>
			<h3 class="menu1"><span class="icon-dashboard"><%=quizCatelogy.getTitle() %></h3>
			<ul>
			<%
				List<QuizCategory> catelogieChild1 = QuizCategoryLocalServiceUtil.getCateByParentId(quizCatelogy.getQuizCategoryId());
				for(QuizCategory quizCatelogy2 : catelogieChild1){
			%>
				<li>
					<h3 class="menu2"><span class="icon-dashboard"></span><%=quizCatelogy2.getTitle() %></h3>
					<ul>	
							
						<%
						List<QuizCategory> catelogieChild2 = QuizCategoryLocalServiceUtil.getCateByParentId(quizCatelogy2.getQuizCategoryId());
						int i =0;
						for(QuizCategory quizCatelogy3 : catelogieChild2){
						%>
						<portlet:actionURL var="getCategoryId" name="getQuizByCategory">
							<portlet:param name="caId" value="<%=String.valueOf(quizCatelogy3.getQuizCategoryId()) %>"/>
						</portlet:actionURL>
							<li><a href="<%=getCategoryId%>"><%=quizCatelogy3.getTitle() %></a></li>
						<%
						}
						%>
					</ul>
				</li>													
				<%
				}
			%>
			</ul>
		</li>
		<%
 		}
 		%>
	</ul>	
</div>

<%
	if(request.getAttribute("listQuiz") != null){
		List<Quiz> quizs = (List<Quiz>)request.getAttribute("listQuiz");
		
		for(Quiz quiz : quizs){
		%>
			<portlet:renderURL var="getListQuestion">
				<portlet:param name="quizId" value="<%=String.valueOf(quiz.getQuizId()) %>"/>
				<portlet:param name="jspPage" value="/html/exam/start.jsp"/>
			</portlet:renderURL>
			<a href="<%=getListQuestion%>"><%=quiz.getTitle() %></a>	
		<%
		}
	}
	else{
		%>
			<a>hihihihihihihihi</a>
		<%
	}
%>

